package com.summer.safe.base;

import com.summer.safe.system.entity.User;
import com.summer.safe.utils.SessionUtils;

import java.io.Serializable;

public class Principal implements Serializable {

    /**
     * 授权用户信息
     */

        private static final long serialVersionUID = 1L;
        /**
         * 编号
         */
        private String id;
        /**
         * 登录名
         */
        private String loginName;
        /**
         * 姓名
         */
        private String name;


        public Principal(User user) {
            this.id = user.getId();
            this.loginName = user.getLoginName();
            this.name = user.getName();
        }

        public String getId() {
            return id;
        }

        public String getLoginName() {
            return loginName;
        }

        public String getName() {
            return name;
        }


        /**
         * 获取SESSIONID
         */
        public String getSessionid() {
            try {
                return (String) SessionUtils.getSession().getId();
            } catch (Exception e) {
                return "";
            }
        }

        @Override
        public String toString() {
            return id;
        }

    }

